package org.leiyang.repository;

import org.leiyang.common.entities.User;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

public interface UserRepository extends ReactiveCrudRepository<User, Long> {
    /**
     * 根据用户名查询用户信息
     * @param name 用户名
     * @return 用户信息
     */
    @Query("SELECT * FROM user WHERE username = :name")
    Mono<User> findUserByName(String name);

    /**
     * 批量获取用户信息
     * @param uIds 用户ID集合（逗号分隔）
     * @return 用户列表
     */
    @Query("SELECT * FROM user WHERE id IN (:uIds)")
    Flux<User> listUsersByIds(@Param("uIds") List<String> uIds);
}
